/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.DictionaryDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.DictionaryDO;
import java.util.List;
import org.springframework.dao.DataAccessException;
import java.util.Map;
import java.util.HashMap;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.DictionaryDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_dictionary.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisDictionaryDAO extends SqlMapClientDaoSupport implements DictionaryDAO {

    /**
     *  Query DB table <tt>sgw_dictionary</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, name, type, is_sensitive, gmt_create, gmt_modified from sgw_dictionary</tt>
     *
     *	@return List<DictionaryDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<DictionaryDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-DICTIONARY-LOAD-ALL", null);

    }

    /**
     *  Insert one <tt>DictionaryDO</tt> object to DB table <tt>sgw_dictionary</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_dictionary(id,name,type,is_sensitive,gmt_create,gmt_modified) values (?, ?, ?, ?, sysdate, sysdate)</tt>
     *
     *	@param dictionary
     *	@return String
     *	@throws DataAccessException
     */
    public String insert(DictionaryDO dictionary) throws DataAccessException {
        if (dictionary == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-DICTIONARY-INSERT", dictionary);

        return dictionary.getId();
    }

    /**
     *  Update DB table <tt>sgw_dictionary</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_dictionary set name=?, type=?, is_sensitive=?, gmt_modified=sysdate where (id = ?)</tt>
     *
     *	@param name
     *	@param type
     *	@param isSensitive
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int update(String name, String type, String isSensitive, String id)
                                                                              throws DataAccessException {
        Map param = new HashMap();

        param.put("name", name);
        param.put("type", type);
        param.put("isSensitive", isSensitive);
        param.put("id", id);

        return getSqlMapClientTemplate().update("MS-DICTIONARY-UPDATE", param);
    }

    /**
     *  Delete records from DB table <tt>sgw_dictionary</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>delete from sgw_dictionary where (id = ?)</tt>
     *
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    public int delete(String id) throws DataAccessException {

        return getSqlMapClientTemplate().delete("MS-DICTIONARY-DELETE", id);
    }

    /**
     *  Query DB table <tt>sgw_dictionary</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, name, type, is_sensitive, gmt_create, gmt_modified from sgw_dictionary where ((id = ?) AND (name = ?) AND (type = ?))</tt>
     *
     *	@param id
     *	@param name
     *	@param type
     *	@return List<DictionaryDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public List<DictionaryDO> select(String id, String name, String type)
                                                                         throws DataAccessException {
        Map param = new HashMap();

        param.put("id", id);
        param.put("name", name);
        param.put("type", type);

        return getSqlMapClientTemplate().queryForList("MS-DICTIONARY-SELECT", param);

    }

    /**
     *  Query DB table <tt>sgw_dictionary</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, name, type, is_sensitive, gmt_create, gmt_modified from sgw_dictionary where (id = ?)</tt>
     *
     *	@param id
     *	@return DictionaryDO
     *	@throws DataAccessException
     */
    public DictionaryDO selectById(String id) throws DataAccessException {

        return (DictionaryDO) getSqlMapClientTemplate().queryForObject(
            "MS-DICTIONARY-SELECT-BY-ID", id);

    }

}